#include<stdio.h>
#include<fcntl.h>
#include<unistd.h>
#include<sys/ioctl.h>
#include<sys/types.h>
#include<sys/stat.h>

int main(int argc, char const *argv[])
{
    int fd;
    int ret;
    fd = open("/dev/beep", O_RDWR);
    if(fd < 0){
        perror("open:");
        return -1;
    }
    while(1){
        printf("********************buzzer On********************\n");
        ret = ioctl(fd, 1, 1);
        if(ret < 0){
            perror("ioctl:");
            return -1;
        }
        sleep(2);
        printf("********************buzzer Off********************\n");
        ret = ioctl(fd, 0, 1);
        if(ret < 0){
            perror("ioctl:");
            return -1;
        }
        sleep(2);
    }
    close(fd);
    return 0;
}
